package io.jt808.proto.item;


import io.norland.buffer.AutoBuffer;
import io.norland.proto.IProto;


public class PositionAdditional12InOutAreaAlarmAdditional implements IProto {
    private int positionType;
    private int areaId;
    private int direction;

    public byte[] writeToBytes() {
        AutoBuffer buffer = new AutoBuffer();
        buffer.writeByte(this.positionType);
        buffer.writeInt(this.areaId);
        buffer.writeByte(this.direction);
        return buffer.array();
    }

    public void readFromBuf(AutoBuffer buffer) {
        this.positionType = buffer.readByte();
        this.areaId = buffer.readInt();
        this.direction = buffer.readByte();
    }

    public String getPositionType() {
        switch (positionType) {
            case 1:
                return "圆形区域";
            case 2:
                return "矩形区域";
            case 3:
                return "多边形区域";
            default: //4:
                return "路段";
        }
    }

    public String direction() {
        return direction == 0 ? "进" : "出";
    }
}